package generator.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import generator.domain.AppCategory;
import generator.domain.DataDictionary;
import generator.service.AppCategoryService;
import generator.service.DataDictionaryService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO
 * @author: 李展鹏
 * @date: 2024年05月17日16:43
 */
@Controller
@RequestMapping("/appCateory")
public class AppCateoryController {
    @Resource
    AppCategoryService appCategoryService;
    @Resource
    private DataDictionaryService dataDictionaryService;
    @RequestMapping("/getAppCategory")
    @ResponseBody
    public List<AppCategory> getAppCatrgory(@RequestParam(value = "pid",defaultValue = "1")Integer pid){
        List<AppCategory> appCategory1List = appCategoryService.getAppCategory1List(pid);
       // return JSON.toJSON(appCategory1List);
        return appCategory1List;
    }
    @RequestMapping("/getAppCategory1")
    @ResponseBody
    public String getAppCatrgory1(@RequestParam("tcode")String tcode){
        QueryWrapper<DataDictionary> dataDictionaryQueryWrapper = new QueryWrapper<>();
        dataDictionaryQueryWrapper.eq("typeCode",tcode);
        List<DataDictionary> list = dataDictionaryService.list(dataDictionaryQueryWrapper);
        // return JSON.toJSON(appCategory1List);
        return JSON.toJSONString(list);
    }
}
